package com.study.scala.function

/**
 * 高阶函数
 */
object FunctionTest3 {

  def main(args: Array[String]): Unit = {

    println(fun2((a, b) => a + b, 10, 33))
    println(fun2((a, b) => a - b, 10, 33))
    println(fun2((a, b) => a * b, 10, 33))
    println(fun2((a, b) => a / b, 10, 33))
    println(fun3(1, 2))

    val plus1 = plus(3);
    println(plus1);
    println(plus1(4));

  }

  def fun2(fun: (Int, Int) => Int, x1: Int, x2: Int): Int = {
    return fun(x1, x2);
  }

  val fun3 = (a: Int, b: Int) => a + b

  def plus(a: Int) = (b: Int) => a + b;
}